home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Pararena 1.3 / source / Parts ƒ / Initialize.p < prev    next >
Encoding:
Text File  |  1991-05-15  |  22.8 KB  |  899 lines  |  [TEXT/PJMM]

  1. unit Initialize;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Sound, Globals, Unlock, Utilities, Guts;
  7.  
  8.     const
  9.         objectPictID = 2000;
  10.         objectPictID2 = 2003;
  11.  
  12.     procedure InitVariables;
  13.  
  14. implementation
  15.  
  16. {=================================}
  17.  
  18.     procedure InitVariables;
  19.         var
  20.             index: Integer;
  21.             tempRect: Rect;
  22.             tempStr: Str255;
  23.  
  24. {-----------------------}
  25.  
  26.         procedure CheckOurEnvirons;
  27.             const
  28.                 WNETrapNum = $60;
  29.                 unimplTrapNum = $9F;
  30.             var
  31.                 err: OSErr;
  32.                 thisWorld: SysEnvRec;
  33.         begin
  34.             rightOffset := (ScreenBits.bounds.right - 512) div 2;
  35.             downOffset := (ScreenBits.bounds.bottom - 342) div 2;
  36.  
  37.             err := SysEnvirons(1, thisWorld);
  38.             with thisWorld do
  39.                 begin
  40.                     if ((machineType < env512KE) and (machineType <> 0)) then
  41.                         FatalError;
  42.                     inhibitSound := (systemVersion < $0602);
  43.  
  44.                     inColor := HasColorQD;
  45.                 end;
  46.  
  47.             hasWNE := (NGetTrapAddress(WNETrapNum, ToolTrap) <> NGetTrapAddress(unimplTrapNum, toolTrap));
  48.         end;
  49.  
  50. {-----------------------}
  51.  
  52.         procedure GetAllSounds;
  53.             var
  54.                 i, howManySounds: Integer;
  55.         begin
  56.             howManySounds := Count1Resources('snd ');        {Get number of sounds}
  57.  
  58.             for i := 1 to howManySounds do
  59.                 begin
  60.                     theSnd := Get1IndResource('snd ', i);
  61.                     if (theSnd^ <> nil) then
  62.                         begin
  63.                             MoveHHi(theSnd);
  64.                             HLock(theSnd);
  65.                         end
  66.                     else
  67.                         Exit(GetAllSounds);
  68.                 end;
  69.         end;
  70.  
  71. {-----------------------}
  72.  
  73.         procedure SetUpMenus;                {Initialize the menus}
  74.             var
  75.                 theMenu: MenuHandle;
  76.         begin
  77.             ClearMenuBar;                {Clear any old menu bars}
  78.             theMenu := GetMenu(mApple);
  79.             AddResMenu(theMenu, 'DRVR');
  80.             InsertMenu(theMenu, 0);
  81.  
  82.             theMenu := GetMenu(mGame);
  83.             InsertMenu(theMenu, 0);
  84.  
  85.             theMenu := GetMenu(mWhichGame);
  86.             InsertMenu(theMenu, -1);
  87.  
  88.             theMenu := GetMenu(mOpponents);
  89.             InsertMenu(theMenu, -1);
  90.  
  91.             theMenu := GetMenu(mOptions);
  92.             InsertMenu(theMenu, 0);
  93.  
  94.             theMenu := NewMenu(133, '(status = LOCKED)');
  95.             InsertMenu(theMenu, 0);
  96.  
  97.             DisableItem(GetMenu(mGame), iEnd);
  98.             CheckItem(GetMenu(mWhichGame), iDeltaFive, TRUE);
  99.             CheckItem(GetMenu(mOpponents), iGeorge, TRUE);
  100.             CheckItem(GetMenu(mOptions), iVisCurs, cursorVis);
  101.             CheckItem(GetMenu(mOptions), iAutoPickUp, autoPickUp);
  102.  
  103.             if (inhibitSound) then
  104.                 begin
  105.                     SetItem(GetMenu(mOptions), iSound, 'Sound need Sys. 6.02 or >');
  106.                     DisableItem(GetMenu(mOptions), iSound);
  107.                 end;
  108.  
  109.             if (locked) then
  110.                 begin
  111.                     DisableItem(GetMenu(mWhichGame), iFourOfNine);
  112.                     DisableItem(GetMenu(mWhichGame), iFirstTo13);
  113.                     DisableItem(GetMenu(mOpponents), iMara);
  114.                     DisableItem(GetMenu(mOpponents), iClaire);
  115.                     DisableItem(GetMenu(mOptions), iPhysics);
  116.                 end
  117.             else
  118.                 begin
  119.                     DeleteMenu(133);
  120.                 end;
  121.  
  122.             HideMenuBar;
  123.             ShowMenuBar;
  124.  
  125.             DrawMenuBar;
  126.         end;
  127.  
  128. {-----------------------}
  129.  
  130.         function NewBitMap (var theBitMap: BitMap; theRect: Rect): Ptr;
  131.         begin
  132.             with theBitMap, theRect do
  133.                 begin
  134.                     rowBytes := ((right - left + 15) div 16) * 2;
  135.                     baseAddr := NewPtr(rowBytes * (bottom - top));
  136.                     bounds := theRect;
  137.                     if (MemError <> noErr) then
  138.                         FatalError
  139.                     else
  140.                         NewBitMap := baseAddr;
  141.                 end;
  142.         end;
  143.  
  144. {-----------------------}
  145.  
  146.         procedure InitForceTable;
  147.             var
  148.                 indexX, indexZ: Integer;
  149.         begin
  150.             vertTable := vertHandle(NewHandle(SIZEOF(vert)));
  151.  
  152.             Handle(vertTable) := GetResource('vert', 2000);
  153.             if (vertTable = nil) then
  154.                 FatalError;
  155.  
  156.             theForces := forceHandle(NewHandle(SIZEOF(force)));
  157.             Handle(theForces) := GetResource('forc', 2000);
  158.             if (theForces = nil) then
  159.                 FatalError;
  160.             MoveHHi(Handle(theForces));
  161.             HLock(Handle(theForces));
  162.             with theForces^^ do
  163.                 for indexX := -24 to 24 do
  164.                     for indexZ := -24 to 24 do
  165.                         begin
  166.                             forceTable[indexX, indexZ, 0] := data[indexX, indexZ, 0];
  167.                             forceTable[indexX, indexZ, 1] := data[indexX, indexZ, 1];
  168.                         end;
  169.             ReleaseResource(Handle(theForces));
  170.             HUnlock(Handle(theForces));
  171.             DisposHandle(Handle(theForces));
  172.         end;
  173.  
  174. {-----------------------}
  175.  
  176.         procedure CreateRegions;
  177.         begin
  178.             wholeRgn := NewRgn;
  179.             SetRectRgn(wholeRgn, 0, 0, 512, 342);
  180.  
  181.             tileRgns[0, 0] := NewRgn;
  182.             MoveTo(219, 213);
  183.             OpenRgn;
  184.             LineTo(183, 198);
  185.             LineTo(199, 185);
  186.             LineTo(226, 175);
  187.             LineTo(240, 200);
  188.             LineTo(226, 205);
  189.             LineTo(219, 213);
  190.             CloseRgn(tileRgns[0, 0]);
  191.  
  192.             tileRgns[1, 0] := NewRgn;
  193.             MoveTo(219, 213);
  194.             OpenRgn;
  195.             LineTo(183, 198);
  196.             LineTo(147, 183);
  197.             LineTo(172, 161);
  198.             LineTo(211, 148);
  199.             LineTo(226, 175);
  200.             LineTo(240, 200);
  201.             LineTo(226, 205);
  202.             LineTo(219, 213);
  203.             CloseRgn(tileRgns[1, 0]);
  204.  
  205.             tileRgns[2, 0] := NewRgn;
  206.             MoveTo(183, 198);
  207.             OpenRgn;
  208.             LineTo(147, 183);
  209.             LineTo(109, 163);
  210.             LineTo(144, 135);
  211.             LineTo(195, 116);
  212.             LineTo(211, 148);
  213.             LineTo(226, 175);
  214.             LineTo(199, 185);
  215.             LineTo(183, 198);
  216.             CloseRgn(tileRgns[2, 0]);
  217.  
  218.             tileRgns[3, 0] := NewRgn;
  219.             MoveTo(147, 183);
  220.             OpenRgn;
  221.             LineTo(109, 163);
  222.             LineTo(74, 142);
  223.             LineTo(118, 104);
  224.             LineTo(180, 81);
  225.             LineTo(195, 116);
  226.             LineTo(211, 148);
  227.             LineTo(172, 161);
  228.             LineTo(147, 183);
  229.             CloseRgn(tileRgns[3, 0]);
  230.  
  231.             tileRgns[4, 0] := NewRgn;
  232.             MoveTo(109, 163);
  233.             OpenRgn;
  234.             LineTo(74, 142);
  235.             LineTo(35, 115);
  236.             LineTo(86, 72);
  237.             LineTo(165, 44);
  238.             LineTo(180, 81);
  239.             LineTo(195, 116);
  240.             LineTo(144, 135);
  241.             LineTo(109, 163);
  242.             CloseRgn(tileRgns[4, 0]);
  243.  
  244.             tileRgns[5, 0] := NewRgn;
  245.             MoveTo(74, 142);
  246.             OpenRgn;
  247.             LineTo(35, 115);
  248.             LineTo(86, 72);
  249.             LineTo(165, 44);
  250.             LineTo(180, 81);
  251.             LineTo(118, 104);
  252.             LineTo(74, 142);
  253.             CloseRgn(tileRgns[5, 0]);
  254.  
  255.             tileRgns[0, 1] := NewRgn;
  256.             MoveTo(512 - 219, 213);
  257.             OpenRgn;
  258.             LineTo(512 - 183, 198);
  259.             LineTo(512 - 199, 185);
  260.             LineTo(512 - 226, 175);
  261.             LineTo(512 - 240, 200);
  262.             LineTo(512 - 226, 205);
  263.             LineTo(512 - 219, 213);
  264.             CloseRgn(tileRgns[0, 1]);
  265.  
  266.             tileRgns[1, 1] := NewRgn;
  267.             MoveTo(512 - 219, 213);
  268.             OpenRgn;
  269.             LineTo(512 - 183, 198);
  270.             LineTo(512 - 147, 183);
  271.             LineTo(512 - 172, 161);
  272.             LineTo(512 - 211, 148);
  273.             LineTo(512 - 226, 175);
  274.             LineTo(512 - 240, 200);
  275.             LineTo(512 - 226, 205);
  276.             LineTo(512 - 219, 213);
  277.             CloseRgn(tileRgns[1, 1]);
  278.  
  279.             tileRgns[2, 1] := NewRgn;
  280.             MoveTo(512 - 183, 198);
  281.             OpenRgn;
  282.             LineTo(512 - 147, 183);
  283.             LineTo(512 - 109, 163);
  284.             LineTo(512 - 144, 135);
  285.             LineTo(512 - 195, 116);
  286.             LineTo(512 - 211, 148);
  287.             LineTo(512 - 226, 175);
  288.             LineTo(512 - 199, 185);
  289.             LineTo(512 - 183, 198);
  290.             CloseRgn(tileRgns[2, 1]);
  291.  
  292.             tileRgns[3, 1] := NewRgn;
  293.             MoveTo(512 - 147, 183);
  294.             OpenRgn;
  295.             LineTo(512 - 109, 163);
  296.             LineTo(512 - 74, 142);
  297.             LineTo(512 - 118, 104);
  298.             LineTo(512 - 180, 81);
  299.             LineTo(512 - 195, 116);
  300.             LineTo(512 - 211, 148);
  301.             LineTo(512 - 172, 161);
  302.             LineTo(512 - 147, 183);
  303.             CloseRgn(tileRgns[3, 1]);
  304.  
  305.             tileRgns[4, 1] := NewRgn;
  306.             MoveTo(512 - 109, 163);
  307.             OpenRgn;
  308.             LineTo(512 - 74, 142);
  309.             LineTo(512 - 35, 115);
  310.             LineTo(512 - 86, 72);
  311.             LineTo(512 - 165, 44);
  312.             LineTo(512 - 180, 81);
  313.             LineTo(512 - 195, 116);
  314.             LineTo(512 - 144, 135);
  315.             LineTo(512 - 109, 163);
  316.             CloseRgn(tileRgns[4, 1]);
  317.  
  318.             tileRgns[5, 1] := NewRgn;
  319.             MoveTo(512 - 74, 142);
  320.             OpenRgn;
  321.             LineTo(512 - 35, 115);
  322.             LineTo(512 - 86, 72);
  323.             LineTo(512 - 165, 44);
  324.             LineTo(512 - 180, 81);
  325.             LineTo(512 - 118, 104);
  326.             LineTo(512 - 74, 142);
  327.             CloseRgn(tileRgns[5, 1]);
  328.  
  329.             ballVisRgn := NewRgn;
  330.             MoveTo(0, 342);
  331.             OpenRgn;
  332.             LineTo(0, 82);
  333.             LineTo(146, 0);
  334.             LineTo(365, 0);
  335.             LineTo(512, 82);
  336.             LineTo(512, 342);
  337.             LineTo(0, 342);
  338.             CloseRgn(ballVisRgn);
  339.         end;
  340.  
  341. {-----------------------}
  342.  
  343.         procedure ReadyBitmaps;
  344.             var
  345.                 rawPointer: Ptr;
  346.                 thePict: PicHandle;
  347.                 tempRect: Rect;
  348.         begin
  349.             SetRect(wholeScreen, 0, 0, 512, 342);
  350.             SetRect(screenArea, 0, 0, 512, 322);
  351.  
  352.             rawPointer := NewPtr(SizeOf(GrafPort));    {Initialize and setup offscreen virgin map}
  353.             offVirginPort := GrafPtr(rawPointer);
  354.             OpenPort(offVirginPort);
  355.             offVirginBits := NewBitMap(offVirginMap, wholeScreen);
  356.             SetPortBits(offVirginMap);
  357.             EraseRect(offVirginMap.bounds);
  358.             SetPort(offVirginPort);
  359.             ClipRect(wholeScreen);
  360.  
  361.             rawPointer := NewPtr(SizeOf(GrafPort));    {Initialize and setup offscreen}
  362.             offLoadPort := GrafPtr(rawPointer);
  363.             OpenPort(offLoadPort);
  364.             offLoadBits := NewBitMap(offLoadMap, wholeScreen);
  365.             SetPortBits(offLoadMap);
  366.             EraseRect(offLoadMap.bounds);
  367.             SetPort(offLoadPort);
  368.             ClipRect(wholeScreen);
  369.  
  370.             rawPointer := NewPtr(SizeOf(GrafPort));    {Initialize and setup offscreen}
  371.             offPlayerPort := GrafPtr(rawPointer);
  372.             OpenPort(offPlayerPort);
  373.             offPlayerBits := NewBitMap(offPlayerMap, screenArea);
  374.             SetPortBits(offPlayerMap);
  375.             EraseRect(offPlayerMap.bounds);
  376.             SetPort(offPlayerPort);
  377.             thePict := GetPicture(objectPictID);
  378.             if (thePict <> nil) then
  379.                 begin
  380.                     HLock(Handle(thePict));
  381.                     tempRect := thePict^^.picFrame;
  382.                     DrawPicture(thePict, tempRect);     {Draw this picture}
  383.                     HUnlock(Handle(thePict));
  384.                     ReleaseResource(Handle(thePict));
  385.                 end
  386.             else
  387.                 FatalError;
  388.             ClipRect(tempRect);
  389.  
  390.             rawPointer := NewPtr(SizeOf(GrafPort));    {Initialize and setup offscreen}
  391.             offEnemyPort := GrafPtr(rawPointer);
  392.             OpenPort(offEnemyPort);
  393.             offEnemyBits := NewBitMap(offEnemyMap, screenArea);
  394.             SetPortBits(offEnemyMap);
  395.             EraseRect(offEnemyMap.bounds);
  396.             SetPort(offEnemyPort);
  397.             thePict := GetPicture(objectPictID2);
  398.             if (thePict <> nil) then
  399.                 begin
  400.                     HLock(Handle(thePict));
  401.                     tempRect := thePict^^.picFrame;
  402.                     DrawPicture(thePict, tempRect);     {Draw this picture}
  403.                     HUnlock(Handle(thePict));
  404.                     ReleaseResource(Handle(thePict));
  405.                 end
  406.             else
  407.                 FatalError;
  408.             ClipRect(tempRect);
  409.         end;
  410.  
  411. {-----------------------}
  412.  
  413.         function PrepareSounds: Boolean;
  414.             var
  415.                 howManySounds, i: Integer;
  416.         begin
  417.             PrepareSounds := FALSE;
  418.  
  419.             chanPtr := nil;
  420.             soundPriority := noSound;
  421.  
  422.             howManySounds := Count1Resources('snd ');        {Get number of sounds}
  423.  
  424.             for i := 1 to howManySounds do
  425.                 begin
  426.                     theSnd := Get1IndResource('snd ', i);
  427.                     if (theSnd <> nil) then
  428.                         begin
  429.                             MoveHHi(theSnd);
  430.                             HLock(theSnd);
  431.                         end
  432.                     else
  433.                         Exit(PrepareSounds);
  434.                 end;
  435.             PrepareSounds := TRUE;
  436.         end;
  437.  
  438. {-----------------------}
  439.  
  440.         procedure ReadInScores;
  441.             type
  442.                 scoreHandle = ^scorePtr;
  443.                 scorePtr = ^score;
  444.                 score = record
  445.                         data: array[0..47] of Integer;
  446.                     end;
  447.  
  448.                 nameHandle = ^namePtr;
  449.                 namePtr = ^name;
  450.                 name = record
  451.                         data: array[0..11, 0..14] of Char;
  452.                     end;
  453.  
  454.                 gamePrefs = record
  455.                         isLocked, isSoundOn: Boolean;
  456.                         isSoundArray: array[1..5] of Boolean;
  457.                         whenToLock, isDelayTime: Integer;
  458.                     end;
  459.                 gamePrefsPtr = ^gamePrefs;
  460.                 gamePrefsHand = ^gamePrefsPtr;
  461.  
  462.                 prefHandle = ^prefPtr;
  463.                 prefPtr = ^pref;
  464.                 pref = record
  465.                         data: array[0..24] of Char;
  466.                     end;
  467.  
  468.             var
  469.                 index, index2, i: Integer;
  470.                 dummyStr: Str255;
  471.                 theScores: scoreHandle;
  472.                 theNamesGreat, theNamesDelta: nameHandle;
  473.                 thePrefs: prefHandle;
  474.                 theGamePrefs: gamePrefsHand;
  475.         begin
  476.             theScores := scoreHandle(NewHandle(SIZEOF(score)));
  477.             Handle(theScores) := GetResource('scrs', 128);
  478.             MoveHHi(Handle(theScores));
  479.             HLock(Handle(theScores));
  480.             with hiScores do
  481.                 for index := 0 to 11 do
  482.                     begin
  483.                         greatScores[index, 0] := theScores^^.data[index];
  484.                         greatScores[index, 1] := theScores^^.data[index + 12];
  485.                         deltaScores[index, 0] := theScores^^.data[index + 24];
  486.                         deltaScores[index, 1] := theScores^^.data[index + 36];
  487.                     end;
  488.             HUnlock(Handle(theScores));
  489.             ReleaseResource(Handle(theScores));
  490.             DisposHandle(Handle(theScores));
  491.  
  492.             theNamesGreat := nameHandle(NewHandle(SIZEOF(name)));
  493.             Handle(theNamesGreat) := GetResource('name', 128);
  494.             MoveHHi(Handle(theNamesGreat));
  495.             HLock(Handle(theNamesGreat));
  496.             with hiScores do
  497.                 for index := 0 to 11 do
  498.                     begin
  499.                         dummyStr := '';
  500.                         for index2 := 0 to 14 do
  501.                             begin
  502.                                 dummyStr := CONCAT(dummyStr, theNamesGreat^^.data[index, index2]);
  503.                             end;
  504.                         greatNames[index] := dummyStr;
  505.                     end;
  506.             HUnlock(Handle(theNamesGreat));
  507.             ReleaseResource(Handle(theNamesGreat));
  508.             DisposHandle(Handle(theNamesGreat));
  509.  
  510.             theNamesDelta := nameHandle(NewHandle(SIZEOF(name)));
  511.             Handle(theNamesDelta) := GetResource('name', 129);
  512.             MoveHHi(Handle(theNamesDelta));
  513.             HLock(Handle(theNamesDelta));
  514.             with hiScores do
  515.                 for index := 0 to 11 do
  516.                     begin
  517.                         dummyStr := '';
  518.                         for index2 := 0 to 14 do
  519.                             begin
  520.                                 dummyStr := CONCAT(dummyStr, theNamesDelta^^.data[index, index2]);
  521.                             end;
  522.                         deltaNames[index] := dummyStr;
  523.                     end;
  524.             HUnlock(Handle(theNamesDelta));
  525.             ReleaseResource(Handle(theNamesDelta));
  526.             DisposHandle(Handle(theNamesDelta));
  527.  
  528.             thePrefs := prefHandle(NewHandle(SIZEOF(pref)));
  529.             Handle(thePrefs) := GetResource('pref', 128);
  530.             MoveHHi(Handle(thePrefs));
  531.             HLock(Handle(thePrefs));
  532.             dummyStr := '';
  533.             for index := 0 to 24 do
  534.                 begin
  535.                     dummyStr := CONCAT(dummyStr, thePrefs^^.data[index]);
  536.                 end;
  537.             prefsStr := dummyStr;
  538.             HUnlock(Handle(thePrefs));
  539.             ReleaseResource(Handle(thePrefs));
  540.             DisposHandle(Handle(thePrefs));
  541.  
  542.             theGamePrefs := gamePrefsHand(NewHandle(SIZEOF(gamePrefs)));
  543.             Handle(theGamePrefs) := GetResource('pref', 129);
  544.             MoveHHi(Handle(theGamePrefs));
  545.             HLock(Handle(theGamePrefs));
  546.             with theGamePrefs^^ do
  547.                 begin
  548.                     soundOn := isSoundOn;
  549.                     if (inhibitSound) then
  550.                         soundOn := FALSE;
  551.  
  552.                     for i := 1 to 5 do
  553.                         soundArray[i] := isSoundArray[i];
  554.  
  555.                     locked := isLocked;
  556.                     timeToLock := whenToLock;
  557.                     if (timeToLock < 2) then
  558.                         begin
  559.                             locked := TRUE;
  560.                             timeToLock := 1;
  561.                         end
  562.                     else
  563.                         timeToLock := timeToLock - 1;
  564.  
  565.                     delayTime := isDelayTime;
  566.                 end;
  567.             HUnlock(Handle(theGamePrefs));
  568.             ReleaseResource(Handle(theGamePrefs));
  569.             DisposHandle(Handle(theGamePrefs));
  570.  
  571.             smallestDelta := hiScores.deltaScores[11, 0] - hiScores.deltaScores[11, 1];
  572.             smallestGreatest := hiScores.greatScores[11, 0];
  573.             scoresChanged := FALSE;
  574.         end;
  575.  
  576. {-----------------------}
  577.  
  578.         procedure OpenMainWndo;
  579.             var
  580.                 thePict: PicHandle;
  581.                 tempRect: Rect;
  582.         begin
  583.             mainWndo := nil;
  584.             mainWndo := GetNewWindow(mainWndoID, nil, Pointer(-1));
  585.             SelectWindow(mainWndo);
  586.             SetPort(mainWndo);
  587.             SizeWindow(mainWndo, screenBits.bounds.right, screenBits.bounds.bottom, FALSE);
  588.             SetOrigin(-rightOffset, -downOffset);
  589.             ShowWindow(mainWndo);
  590.             SetPort(offVirginPort);
  591.  
  592.             thePict := GetPicture(backPictID);
  593.             if (thePict <> nil) then
  594.                 begin
  595.                     HLock(Handle(thePict));
  596.                     tempRect := thePict^^.picFrame;
  597.                     DrawPicture(thePict, tempRect);
  598.                     HUnlock(Handle(thePict));
  599.                     ReleaseResource(Handle(thePict));
  600.                 end
  601.             else
  602.                 FatalError;
  603.  
  604.             SetPort(mainWndo);
  605.             CopyBits(offVirginMap, mainWndo^.portBits, tempRect, tempRect, srcCopy, mainWndo^.visRgn);
  606.             CopyBits(offVirginMap, offLoadMap, tempRect, tempRect, srcCopy, nil);
  607.  
  608.             PenPat(black);
  609.             PenMode(patXOr);
  610.             PenSize(2, 2);
  611.         end;
  612.  
  613. {-----------------------}
  614.  
  615.     begin
  616.         SetCursor(GetCursor(WatchCursor)^^);
  617.         CheckOurEnvirons;
  618.         GetAllSounds;
  619.         ReadInScores;
  620.         SetUpMenus;
  621.         ReadyBitmaps;
  622.         InitForceTable;
  623.         CreateRegions;
  624.         if (not PrepareSounds) then
  625.             FatalError;
  626.         SetUpMouseForce;
  627.         OpenMainWndo;
  628.  
  629.         doneFlag := FALSE;
  630.         playing := FALSE;
  631.         pausing := FALSE;
  632.         jetsOut := FALSE;
  633.         cursorVis := FALSE;
  634.         autoPickUp := FALSE;
  635.  
  636.         whichOpponent := george;
  637.         whichGame := deltaFive;
  638.         mouseConst := 100;
  639.         tileLit := -1;
  640.         tileToggle := 0;
  641.         numberOfStars := 0;
  642.         frictState := normalFriction;
  643.         playerName := 'Anonymous      ';
  644.  
  645.         GetDateTime(randSeed);
  646.  
  647.         ballCatches[0] := 'playerCatch';
  648.         ballCatches[1] := 'maraCatch';
  649.         ballCatches[2] := 'ottoCatch';
  650.         ballCatches[3] := 'georgeCatch';
  651.         ballCatches[4] := 'claireCatch';
  652.  
  653.         cursorArray[0] := GetCursor(4000);
  654.         cursorArray[1] := GetCursor(4001);
  655.         cursorArray[2] := GetCursor(4002);
  656.         cursorArray[3] := GetCursor(4003);
  657.         cursorArray[4] := GetCursor(4004);
  658.         cursorArray[5] := GetCursor(4005);
  659.         cursorArray[6] := GetCursor(4006);
  660.         cursorArray[7] := GetCursor(4007);
  661.         cursorArray[8] := GetCursor(4008);
  662.  
  663.         nontantTable[0] := northWest;
  664.         nontantTable[1] := west;
  665.         nontantTable[2] := southWest;
  666.         nontantTable[3] := north;
  667.         nontantTable[4] := resting;
  668.         nontantTable[5] := south;
  669.         nontantTable[6] := northEast;
  670.         nontantTable[7] := east;
  671.         nontantTable[8] := southEast;
  672.  
  673.         modeOpposites[north] := south;
  674.         modeOpposites[south] := north;
  675.         modeOpposites[east] := west;
  676.         modeOpposites[west] := east;
  677.         modeOpposites[southEast] := northWest;
  678.         modeOpposites[northWest] := southEast;
  679.         modeOpposites[southWest] := northEast;
  680.         modeOpposites[northEast] := southWest;
  681.         modeOpposites[resting] := resting;
  682.  
  683.         massNumbers[0, 0] := 3;
  684.         massNumbers[0, 1] := 2;
  685.         massNumbers[1, 0] := 1;
  686.         massNumbers[1, 1] := 1;
  687.         massNumbers[2, 0] := 2;
  688.         massNumbers[2, 1] := 1;
  689.         massNumbers[3, 0] := 1;
  690.         massNumbers[3, 1] := 1;
  691.         massNumbers[4, 0] := 1;
  692.         massNumbers[4, 1] := 1;
  693.  
  694.         with ball do
  695.             begin
  696.                 SetRect(src, 298, 125, 310, 137);
  697.                 SetRect(mask, 311, 125, 323, 137);
  698.                 mode := 0;
  699.             end;
  700.  
  701.         stars[0, 0] := 26;
  702.         stars[0, 1] := 30;
  703.         stars[1, 0] := 43;
  704.         stars[1, 1] := 24;
  705.         stars[2, 0] := 59;
  706.         stars[2, 1] := 34;
  707.         stars[3, 0] := 48;
  708.         stars[3, 1] := 49;
  709.         stars[4, 0] := 72;
  710.         stars[4, 1] := 79;
  711.         stars[5, 0] := 112;
  712.         stars[5, 1] := 55;
  713.         stars[6, 0] := 41;
  714.         stars[6, 1] := 255;
  715.         stars[7, 0] := 129;
  716.         stars[7, 1] := 303;
  717.         stars[8, 0] := 487;
  718.         stars[8, 1] := 223;
  719.         stars[9, 0] := 495;
  720.         stars[9, 1] := 237;
  721.         stars[10, 0] := 506;
  722.         stars[10, 1] := 266;
  723.         stars[11, 0] := 469;
  724.         stars[11, 1] := 278;
  725.         stars[12, 0] := 200;
  726.         stars[12, 1] := 326;
  727.         stars[13, 0] := 487;
  728.         stars[13, 1] := 57;
  729.         stars[14, 0] := 325;
  730.         stars[14, 1] := 30;
  731.         stars[15, 0] := 17;
  732.         stars[15, 1] := 22;
  733.         stars[16, 0] := 12;
  734.         stars[16, 1] := 15;
  735.         stars[17, 0] := 32;
  736.         stars[17, 1] := 17;
  737.         stars[18, 0] := 61;
  738.         stars[18, 1] := 25;
  739.         stars[19, 0] := 63;
  740.         stars[19, 1] := 37;
  741.         stars[20, 0] := 76;
  742.         stars[20, 1] := 74;
  743.         stars[21, 0] := 96;
  744.         stars[21, 1] := 66;
  745.         stars[22, 0] := 205;
  746.         stars[22, 1] := 11;
  747.         stars[23, 0] := 269;
  748.         stars[23, 1] := 28;
  749.         stars[24, 0] := 255;
  750.         stars[24, 1] := 3;
  751.         stars[25, 0] := 5;
  752.         stars[25, 1] := 225;
  753.         stars[26, 0] := 28;
  754.         stars[26, 1] := 223;
  755.         stars[27, 0] := 12;
  756.         stars[27, 1] := 274;
  757.         stars[28, 0] := 64;
  758.         stars[28, 1] := 276;
  759.         stars[29, 0] := 86;
  760.         stars[29, 1] := 334;
  761.         stars[30, 0] := 437;
  762.         stars[30, 1] := 9;
  763.         stars[31, 0] := 502;
  764.         stars[31, 1] := 58;
  765.         stars[32, 0] := 487;
  766.         stars[32, 1] := 20;
  767.         stars[33, 0] := 381;
  768.         stars[33, 1] := 47;
  769.         stars[34, 0] := 449;
  770.         stars[34, 1] := 83;
  771.         stars[35, 0] := 492;
  772.         stars[35, 1] := 123;
  773.         stars[36, 0] := 489;
  774.         stars[36, 1] := 220;
  775.         stars[37, 0] := 484;
  776.         stars[37, 1] := 232;
  777.         stars[38, 0] := 504;
  778.         stars[38, 1] := 235;
  779.         stars[39, 0] := 508;
  780.         stars[39, 1] := 254;
  781.         stars[40, 0] := 457;
  782.         stars[40, 1] := 258;
  783.         stars[41, 0] := 501;
  784.         stars[41, 1] := 270;
  785.         stars[42, 0] := 320;
  786.         stars[42, 1] := 313;
  787.         stars[43, 0] := 254;
  788.         stars[43, 1] := 328;
  789.         stars[44, 0] := 155;
  790.         stars[44, 1] := 325;
  791.  
  792.         SetRect(playerSrc[south, notCarrying], 1, 1, 33, 48);
  793.         SetRect(playerSrc[southEast, notCarrying], 34, 1, 66, 48);
  794.         SetRect(playerSrc[east, notCarrying], 67, 1, 99, 48);
  795.         SetRect(playerSrc[northEast, notCarrying], 100, 1, 132, 48);
  796.         SetRect(playerSrc[north, notCarrying], 133, 1, 165, 48);
  797.         SetRect(playerSrc[northWest, notCarrying], 166, 1, 198, 48);
  798.         SetRect(playerSrc[west, notCarrying], 199, 1, 231, 48);
  799.         SetRect(playerSrc[southWest, notCarrying], 232, 1, 264, 48);
  800.         SetRect(playerSrc[resting, notCarrying], 265, 1, 297, 48);
  801.  
  802.         for index := south to resting do
  803.             begin
  804.                 playerSrc[index, carrying] := playerSrc[index, notCarrying];
  805.                 OffsetRect(playerSrc[index, carrying], 0, 48);
  806.                 playerSrc[index, crouching] := playerSrc[index, notCarrying];
  807.                 OffsetRect(playerSrc[index, crouching], 0, 96);
  808.             end;
  809.  
  810.         for index := south to resting do
  811.             begin
  812.                 playerMask[index, carrying] := playerSrc[index, carrying];
  813.                 OffsetRect(playerMask[index, carrying], 0, 144);
  814.                 playerMask[index, notCarrying] := playerSrc[index, notCarrying];
  815.                 OffsetRect(playerMask[index, notCarrying], 0, 144);
  816.                 playerMask[index, crouching] := playerSrc[index, crouching];
  817.                 OffsetRect(playerMask[index, crouching], 0, 144);
  818.             end;
  819.  
  820.         for index := south to resting do
  821.             begin
  822.                 opponentSrc[index, notCarrying] := playerSrc[index, notCarrying];
  823.                 opponentSrc[index, carrying] := playerSrc[index, carrying];
  824.                 opponentSrc[index, crouching] := playerSrc[index, crouching];
  825.             end;
  826.  
  827.         SetRect(digitSrc[0], 301, 76, 312, 96);        {0}
  828.         SetRect(digitSrc[1], 317, 76, 328, 96);        {1}
  829.         SetRect(digitSrc[2], 333, 76, 344, 96);        {2}
  830.         SetRect(digitSrc[3], 349, 76, 360, 96);        {3}
  831.         SetRect(digitSrc[4], 365, 76, 376, 96);        {4}
  832.         SetRect(digitSrc[5], 381, 76, 392, 96);        {5}
  833.         SetRect(digitSrc[6], 397, 76, 408, 96);        {6}
  834.         SetRect(digitSrc[7], 413, 76, 424, 96);        {7}
  835.         SetRect(digitSrc[8], 301, 101, 312, 121);        {8}
  836.         SetRect(digitSrc[9], 317, 101, 328, 121);        {9}
  837.         SetRect(digitSrc[10], 301, 76, 312, 96);    {0}
  838.         SetRect(digitSrc[11], 333, 101, 344, 121);    {solid black}
  839.         SetRect(digitSrc[12], 349, 101, 360, 121);    {solid white}
  840.         SetRect(digitSrc[13], 365, 101, 378, 121);    {-}
  841.         SetRect(digitSrc[14], 381, 101, 392, 121);    {>}
  842.         SetRect(digitSrc[15], 397, 101, 408, 121);    {<}
  843.         SetRect(digitSrc[16], 413, 101, 424, 121);    {E}
  844.  
  845.         SetRect(timeDest[1], 21, 304, 32, 324);
  846.         SetRect(timeDest[2], 42, 304, 53, 324);
  847.         SetRect(timeDest[3], 58, 304, 69, 324);
  848.  
  849.         SetRect(earthScoreDest[1], 377, 304, 388, 324);
  850.         SetRect(earthScoreDest[2], 393, 304, 404, 324);
  851.         SetRect(earthScoreDest[3], 409, 304, 420, 324);
  852.  
  853.         SetRect(taygeteScoreDest[1], 449, 304, 460, 324);
  854.         SetRect(taygeteScoreDest[2], 465, 304, 476, 324);
  855.         SetRect(taygeteScoreDest[3], 481, 304, 492, 324);
  856.  
  857.         SetRect(titleSrc[0], 299, 2, 327, 35);    {P}
  858.         SetRect(titleSrc[1], 330, 10, 356, 35);    {a}
  859.         SetRect(titleSrc[2], 359, 10, 385, 35);    {r}
  860.         SetRect(titleSrc[3], 330, 10, 356, 35);    {a}
  861.         SetRect(titleSrc[4], 359, 10, 385, 35);    {r}
  862.         SetRect(titleSrc[5], 388, 10, 414, 35);    {e}
  863.         SetRect(titleSrc[6], 417, 10, 443, 35);    {n}
  864.         SetRect(titleSrc[7], 330, 10, 356, 35);    {a}
  865.  
  866.         SetRect(titleMask[0], 299, 37, 327, 72);    {P}
  867.         SetRect(titleMask[1], 330, 46, 356, 72);    {a}
  868.         SetRect(titleMask[2], 359, 46, 385, 72);    {r}
  869.         SetRect(titleMask[3], 330, 46, 356, 72);    {a}
  870.         SetRect(titleMask[4], 359, 46, 385, 72);    {r}
  871.         SetRect(titleMask[5], 388, 46, 414, 72);    {e}
  872.         SetRect(titleMask[6], 417, 46, 443, 72);    {n}
  873.         SetRect(titleMask[7], 330, 46, 356, 72);    {a}
  874.  
  875.         SetRect(jetsRects[0], 439, 205, 511, 255);
  876.         SetRect(jetsRects[1], 439, 256, 511, 306);
  877.  
  878.         SetRect(teleportMask[0], 298, 241, 330, 288);
  879.         SetRect(teleportMask[1], 331, 241, 363, 288);
  880.         SetRect(teleportMask[2], 364, 241, 396, 288);
  881.         SetRect(teleportMask[3], 397, 241, 429, 288);
  882.  
  883.         SetRect(foulSrc, 330, 38, 335, 43);
  884.         SetRect(foulDest[0, 1], 380, 326, 385, 331);
  885.         SetRect(foulDest[0, 2], 396, 326, 401, 331);
  886.         SetRect(foulDest[0, 3], 412, 326, 417, 331);
  887.         SetRect(foulDest[1, 1], 452, 326, 457, 331);
  888.         SetRect(foulDest[1, 2], 468, 326, 473, 331);
  889.         SetRect(foulDest[1, 3], 484, 326, 489, 331);
  890.  
  891.         SetRect(periodDest[1], 23, 326, 28, 331);
  892.         SetRect(periodDest[2], 36, 326, 41, 331);
  893.         SetRect(periodDest[3], 49, 326, 54, 331);
  894.         SetRect(periodDest[4], 62, 326, 67, 331);
  895.     end;
  896.  
  897. {=================================}
  898.  
  899. end.